First, you need to install Snow Leopard after which you can upgrade further to whatever your model supports.
You can purchase Snow Leopard through the Apple Store:Mac OS X 10.6 Snow Leopard - Apple Store (U.S.). The price is $19.99 plus tax. You will be sent physical media by mail after placing your order.
After you install Snow Leopard you will have to download and install the Mac OS X 10.6.8 Update Combo v1.1 to update Snow Leopard to 10.6.8 and give you access to the App Store. Access to the App Store enables you to download Mavericks if your computer meets the requirements.
Should your model require Snow Leopard later than 10.6.3, then you need the install discs that came with the computer.